package com.leapp.sk.ui.adapter

import android.content.Context
import cc.vv.lkimcomponent.lkim.bean.LKIMConversation
import cc.vv.lkimcomponent.lkim.bean.LKIMMessage
import com.example.mvp.adapter.BaseLibMultipleViewAdapter
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.delegate.BaseAdapterDelegate
import com.leapp.sk.binder.im.SingleChatAdapterBinder
import com.leapp.sk.viewdelegate.adapter.MessageAdalterDelegate


/**
 * 消息会话列表适配器
 * @author  chaohaipeng  on 2018/7/24.
 */
class MessageListAdapter (context: Context, mlist: List<LKIMConversation>) : BaseLibMultipleViewAdapter<LKIMConversation>(context, mlist){
    /**
     * 表情数据
     */
    val mList = mlist
    /**
     * 上下文
     */
    val mContext = context
    override fun bindEvenListener(viewDelegate: BaseAdapterDelegate?, position: Int) {
    }

    override fun notifyView(viewDelegate: BaseAdapterDelegate?, position: Int) {
           if (viewDelegate is MessageAdalterDelegate){
               viewDelegate.setData(mContext,mList.get(position))
           }

    }

    override fun getDelegate(position: Int): BaseAdapterDelegate {
        return MessageAdalterDelegate::class.java?.newInstance()
    }

    override fun getDataBinder(position: Int): BaseDataBinder<*, *> {
        return SingleChatAdapterBinder()
    }

    override fun getItemData(position: Int): Any {
        return mList.get(position)
    }
}